from pyroute2 import IPRoute
# from pyroute2.netlink.rtnl.ifaddrmsg import ifaddrmsg
from pydantic import BaseModel
from pydantic.networks import IPvAnyAddress

class NetworkInformation(BaseModel):
    ifname: str
    mac: str

def main():
    with IPRoute() as ipr:
        for msg in ipr.addr("dump"):
            if msg.get('index') == 2:
                print(msg)
                if_index = msg.get('index')
                if_name = msg.get('label')
                address = msg.get('address')
                mask = msg.get('prefixlen')
                print(f"{if_index} {if_name}: {address}/{mask}")


if __name__ == "__main__":
    main()